package cn.gok.review;
class Worker{
    private String name;
    private String job;
    private int salary;
    public  int  doJob(int months){
        System.out.println(name+"板砖工作了"+months+"个月，获得"+salary*months+"工资");
        return salary*months;
    }

    public Worker(String name, String job, int salary) {
        this.name = name;
        this.job = job;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", job='" + job + '\'' +
                ", salary=" + salary +
                '}';
    }


}

class SuperWorker extends Worker{
    float bonus = (float) Math.random();
    public SuperWorker(String name, String job, int salary) {
        super(name, job, salary);
    }

    public  int  doJob(int months){
        System.out.println(super.getName()+"板砖工作了"+months+"个月，获得"+super.getSalary()*months*(1+bonus)+"工资");
        return (int) (super.getSalary()*months*(1+bonus));
    }

    public  int  doJob(int months,int addtionalHours){
        //返回不带加班时间的doJob返回值 +  bonus*salary*addtionalHours/100
        return (int) (bonus*super.getSalary()*addtionalHours/100)+addtionalHours;
    }
}

public class Homework2 {
    public static void main(String[] args) {
        Worker worker = new Worker("小明","板砖",6000);
        worker.doJob(6);

        SuperWorker superWorker = new SuperWorker("小刘","敲代码",6000);
        System.out.println(superWorker.doJob(6));
        System.out.println(superWorker.doJob(6,20));
    }
}
